//
//  CardFlipView.swift
//  TanTan_Kotlin
//
//  Created by EDY on 5/26/25.
//

import SwiftUI

struct CardFlipView : View {
    @State private var isFlipped = false
    @State private var rotationAngle = 0.0
    var body: some View {
             ZStack {
                 RoundedRectangle(cornerRadius: 20)
                     .fill(isFlipped ? Color.blue : Color.red)
                     .frame(width: 200, height: 300)
                     .overlay(
                         Text(isFlipped ? "卡片反面" : "卡片正面")
                             .font(.largeTitle)
                             .foregroundColor(.white)
                     )
                     .rotation3DEffect(.degrees(rotationAngle), axis: (x: 0, y: 1, z: 0))
                     .onTapGesture {
                         withAnimation(.spring()) {
                             rotationAngle += 180
                             isFlipped.toggle()
                         }
                     }
             }
         }
}


#Preview {
    CardFlipView()
}
